/**
 * 组件代码
 */
Vue.component('comSougnVideo', {
    name: 'comSougnVideo',
    props: ['config', 'data'],
    data: function () {
        return {
            content: "",
        }
    },
    computed: {
        myConfig: function () {
            var data = {};
            for (var item of this.config) {
                data[item.id] = item.value;
            }
            return data;
        },
    },
    watch: {
        data: function (oldValue, newValue) {
            this.dataChange();
        }
    },
    mounted() {
        this.dataChange();
    },
    methods: {
        dataChange: function () {
            var data = window.getValue(this.myConfig.data);
            if (typeof (data[0]) == 'string') {
                this.content = data[0];
            } else if (data[0] != undefined && data[0][0] != undefined) {
                this.content = data[0][0];
            } else {
                this.content = "";
            }
        }
    },
    template: `<div :style="myConfig"><video width="100%" height="100%" :controls="myConfig.controls" preload="auto" :muted="myConfig.muted" :loop="myConfig.loop" >
    <source :src="myConfig.sources"   type="video/mp4" >
</video></div>`,
});
/**
 * 配置项
 * @type {{name: string, id: string, type: string, value: string}[]}
 */
var comSougnVideoConfig = [{
    name: "视屏源",
    type: "text",
    value: "",
    id: "sources"
}, {
    name: "播放次数",
    type: "select",
    value: "loop",
    config: [
        {
            value: 'loop',
            label: '循环播放'
        }, {
            value: 'not',
            label: '就一次'
        }],
    id: "loop"
}, {
    name: "是否显示播放按钮",
    type: "select",
    value: "controls",
    config: [
        {
            value: 'not',
            label: '不显示'
        }, {
            value: 'controls',
            label: '显示'
        }],
    id: "controls"
}, {
    name: "是否静音",
    type: "select",
    value: "muted",
    config: [
        {
            value: 'not',
            label: '不静音'
        }, {
            value: 'muted',
            label: '静音'
        }],
    id: "muted"
}]
